//
//  TableShowCollectionViewCell+Conifg.swift
//  CooperSwift
//
//  Created by 计海峰 on 2022/1/19.
//

import Foundation

public extension TableShowCollectionViewCell {
    
    //MARK: - 写布局
    func layoutViews() {
        contentView.addSubview(collectionView)
        collectionView.snp.makeConstraints { make in
            make.edges.equalToSuperview().inset(UIEdgeInsets.zero)
        }
    }
    
    //MARK: - 加载图片
    func loadData() {
        guard let cellModel = self.info as? TableShowCollectionViewCellModel else { return }
        // 执行一次配置
        if !cellModel.isConfigDone {
            cellModel.isConfigDone = true
            collectionView.snp.updateConstraints { make in
                make.edges.equalToSuperview().inset(cellModel.margin)
            }
            cellModel.once(collectionView, cell: self)
        }
        cellModel.every(collectionView, cell: self)
    }
    
    
}
